<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ page import="Order.Order" %>
<%@ page import="Page.Page"   %>
<%@ page import="java.util.*"  %>
<%@ page import="Order.SearchOrder"%>
<%
   //从数据库中去出结果集
   int currentRecord = 0;
   int DeleteID=0;
   String sql="";
   int k=0;
   int k1=0;
   Page pager=new Page();
   SearchOrder db=new SearchOrder();
   String SelOrderWay=(String)request.getParameter("SelOrderWay");
   String value=(String)request.getParameter("value");
   if(SelOrderWay==null||value==null)
   {
   	 SelOrderWay="All";
   	 value="11";
   }
   ArrayList<Order> result =db.SelectShow(SelOrderWay,value); 
   out.print("   "+db.mark);
   pager.setTotalRecord(result.size());
   pager.setTotalPage(result.size(),pager.getPageSize());
   //计算并设置分页的参数
   if(request.getParameter("currentRecord")!=null)
   {   
       currentRecord = Integer.parseInt(request.getParameter("currentRecord"));
       pager.setCurrentRecord(currentRecord);
       pager.setCurrentPage(currentRecord,pager.getPageSize());
   }
   //从结果集中取出当前页面要显示的子集
   List<Order> subResult = null;
   if(currentRecord == 0)
   {
       if(currentRecord+pager.getPageSize()<=result.size())
       {
            subResult = result.subList(0,pager.getPageSize());
       	
       }
       else
       {
       	   	subResult = result.subList(0,result.size());
       }
   
   }
   else if(pager.getCurrentRecord()+pager.getPageSize()<result.size())
       subResult = result.subList(pager.getCurrentRecord(),pager.getCurrentRecord

()+pager.getPageSize());
   else
       subResult = result.subList(pager.getCurrentRecord(),result.size());
 %>
<html>
  <head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>购物车</title>
<link href="../css/shopbus.css" rel="stylesheet" type="text/css" />
  </head>

<body>
<form name="From1" method="POST" action="SearchOrder.jsp"
	onsubmit="javaScript: return validate();">
	<table border="0" width="100%" cellspacing="1" bgColor="#cccccc"
		valign=center>
		<tr>
		<td><select size="1" name="SelOrderWay" align=center >
			<option value="All" <%if(SelOrderWay!=null&&SelOrderWay.equals("All"))out.print("selected");%>>全部</option>
			<option value="OrderID" <%if(SelOrderWay!=null&&SelOrderWay.equals("OrderID"))out.print("selected");%>>订单编号</option>
			<option value="BuyerID" <%if(SelOrderWay!=null&&SelOrderWay.equals("BuyerID"))out.print("selected");%> >买家编号</option>
			<option value="SellerID" <%if(SelOrderWay!=null&&SelOrderWay.equals("SellerID"))out.print("selected");%>>卖家编号</option>
			<option value="ComID" <%if(SelOrderWay!=null&&SelOrderWay.equals("ComID"))out.print("selected");%> >商品编号</option>	
		</select>
		</td>
		<td>
		<input type="text" name="value" size="20"
			maxlength="20" value=<%=request.getParameter("value")%> >
			</td>
		 <td width="20%" colspan="2" align=center><input type="submit" value="搜索"
			name="submit"></td>
				</tr>
	</table>
  </form>
<div class="top_img">
</div>
<div class="busWord">
</div>
<div class="bus_order"> 
<table width="963" height="160" border="0">
  <tr>
    <td width="80" height="61"><img src="images/order_5_11.png" /></td>
    <td width="62"><img src="../images/order_5_13.png" /></td>
    <td width="96"><img src="../images/order_5_15.png" /></td>
    <td width="96"><img src="../images/order_5_17.png" /></td>
    <td width="77"><img src="../images/order_5_19.png" width="57" height="14" /></td>
    <td width="80"><img src="../images/order_5_21.png" width="27" height="14" /></td>
    <td width="72"><img src="../images/order_5_25.png" width="56" height="14" /></td>
    <td width="101"><img src="../images/order_5_27.png" width="42" height="14" /></td>
     <td width="99">是否处理</td>
    <td width="105">备注</td>
    <td width="49"><img src="../images/order_5_29.png" width="28" height="14" /></td>
  </tr>
   <%
   			 if(subResult.isEmpty()==false)
		       {
		             for(int i=0;i<subResult.size();i++)
		             {
		                 Order order = subResult.get(i);
						 out.print("<tr>");
		                 out.print("<td>"+order.getOrderID()+"</td>");
		                 out.print("<td>"+order.getBuyerID()+"</td>");
		                 out.print("<td>"+order.getSellerID()+"</td>");
		                 out.print("<td>"+order.getComID()+"</td>");
		                 out.print("<td>"+order.getComName()+"</td>");
		                 out.print("<td>"+order.getOrderNum()+"</td>");
		                 out.print("<td>"+order.getOrderPrice()+"</td>");
		                 out.print("<td>"+order.getOrderTime()+"</td>");
		                 out.print("<td>"+order.getOrderToDate()+"</td>");
		                 out.print("<td>"+order.turn(order.getOrderIsChecked())+"</td>");
		                 out.print("<td>"+order.getOrderInf()+"</td>");
		                 out.print("<td>"+"<a href='DeleteOrder.jsp?DeleteID="+order.getOrderID()+"'>删除 </a>"+"</td>");
		                 out.print("</tr>");   
		             }
		        }
   		 %>	
  <div class="bus_price"></div>
</table>

</div>
<div class="bus_bottom_page">
	<span><font size="2">总<%=pager.getTotalRecord()%>条记录|总<%=pager.getTotalPage()%>页|当

前<%=pager.getCurrentPage()+1%>页|每页<%=pager.getPageSize()%>条|
<% 
    //如果已经到了首页就去掉前一页的链接
    if(pager.getCurrentRecord()-pager.getPageSize()<0)
        out.println("首页|");
    else
    //上一页就是把当前记录位置减去一页显示记录的条数
        out.print("<a href='SearchOrder.jsp?currentRecord="+(pager.getCurrentRecord()-

pager.getPageSize())+"&pageSize="+pager.getPageSize()+"'>上一页</a>|");
    //如果到了尾页就去掉下一页的链接
    if(pager.getCurrentRecord()+pager.getPageSize()>=pager.getTotalRecord())
        out.println("尾页");
    else
    //下一页就是把当前记录位置加上一页显示记录的条数
        out.print("<a href='SearchOrder.jsp?currentRecord="+(pager.getCurrentRecord

()+pager.getPageSize())+"&pageSize="+pager.getPageSize()+"'>下一页</a>|"); 
%>
</font></span>	</div>
</body>
</html>